﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Haha.Att;
using Haha.Mvc;
using System.IO;
namespace Haha.ctrls
{
    [Action(Path="/user")]
    public class UserAction
    {

        [Mvc]
        public string index()
        {
            
            return "haha mvc";
        }
        [Mvc]
        [Layout]
        public string index_v1()
        {
            return "";
        }

        [Mvc]
        [Layout(LayoutName="layout2.cshtml",Title="布局器")]
        public string layouts()
        {
            return "";
        }

        [MvcJson]
        public string t1()
        {
            String json= HahaMap.New.SetV("a", 100).SetV("b", 100).ToJson();
            return json;
        }

        [MvcText]
        public string t2()
        {
            return "<h1>hehe</h1>";
        }

        [MvcDown]
        public MvcDown t3()
        {
           
           return MvcDown.New.SetData(System.IO.File.ReadAllBytes(MvcContext.MvcCtx.Request.MapPath("~/temp/header.cshtml")))
               .SetFileName("测试.txt");
           
        }

        [MvcImage(ImageType="png")]
        public MvcImage t4()
        {
            return MvcImage.New.SetData(System.IO.File.ReadAllBytes(MvcContext.MvcCtx.Request.MapPath("~/user/001_calendar.png")));
        }

        [MvcText]
        public string t5()
        {
            var fd = MvcFormData.New;
            return fd["id"] + "," + fd["a"];
        }

        [Mvc]
        public MvcView t6()
        {
            MvcView mv = new MvcView();
            mv.Obj = HahaMap.New.SetV("a", "100").SetV("b", 200).ToJson();
            mv.Url = "~/user/a";
            mv.MvcViewType = MvcViewType.Json;
            return mv;
        }
      }


}
